<?php

namespace app\index\controller;

class Product extends Base
{
    protected $beforeActionList = [
        'right' => ['only' => 'index,detailed'],
        'images' => ['only' => 'detailed'],
    ];


    /**
     * 更多图片
     */
    public function images()
    {
        $images = model('ProductImages')->where('pid', $this->request->param('id'))->column('image');
        $this->assign([
            'images' => $images,
        ]);
    }

    public function savemass()
    {
        $aa = session('User', '', 'User');

        if (empty($aa->id)) {
//            return ajax_info('请登录再留言！');
            $data['username'] = '匿名';
        } else {
            $data['username'] = $aa->name;
            $data['uid'] = $aa->id;
        }
        if ($this->request->isPost()) {
            $post = $this->request->param();
            $data['aid'] = $post['id'];
            $data['status'] = 1;
            $data['create_time'] = time();
            $data['username'] =!empty($post['name'])? $post['name']:$data['username'];
            $data['center'] = $post['center'];
            $data['tel'] = $post['tel'];
            $list = db('productmass')->insert($data);
            if ($list) {
               // model('article')->save(['update_time' => time()], ['id' => $post['id']]);
                return ajax_info('留言成功', 'u');
            } else {
                return ajax_info('重复留言');

            }
        }

    }

}
